package com.smallyu.order.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @Author: small-yu
 * @Package: com.smallyu.order.config
 * @Project: order
 * @Date: 2024/4/18
 * @Time: 0:25
 * 消息队列初始化
 */
@Configuration
public class YuRabbitMqConfig {

    public final static String PRE_EXCHANGE = "small-yu-exchange:";
    public final static String PRE_QUEUE = "small-yu-queue:";
    public final static String PRE_ROUTING = "small-yu-routing:";

    @Bean
    public DirectExchange directExchange01(){
        return new DirectExchange(PRE_EXCHANGE+"01",true,false);
    }

    @Bean
    public Queue directQueue01(){
        return new Queue(PRE_QUEUE+"01",true);
    }

    @Bean
    public Binding directBinding(){
        return BindingBuilder.bind(directQueue01()).to(directExchange01()).with(PRE_ROUTING+"01");
    }
}
